/**
********************************************************************************
* @file     lvgl_ui_init.c
* @brief    对文件的简要说明
* @details  对文件的详细说明
* @author   jcai
* @date     2024-07-11 00:49:58
* @copyright Copyright &copy; 2024 wy1107412334@163.com All rights reserved
* @version  v0.0.1
*
* \n Email:  wy1107412334@163.com
* \n Blog:   None
* \n Github: https://github.com/wy1107412334
* \n Gitee:  https://gitee.com/git.git1107412334.com
*
********************************************************************************
* @note
* None.
********************************************************************************
* @attention
* None.
********************************************************************************
@verbatim
@endverbatim
********************************************************************************
* @par 历史记录
* jcai, 2024-07-11 00:49:58
* - 首次编写
*
*<center>Copyright &copy; 2024 wy1107412334@163.com All rights reserved</center>
********************************************************************************
*/

/* 头文件导入区 ------------------------------------------------------------- */

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
#include "lvgl_ui_init.h"


/** @defgroup LVGL_UI_INIT LVGL_UI_INIT
* @brief lvgl_ui_init modules
* @{
*/



/* 私有宏定义区 ------------------------------------------------------------- */





/* 私有数据类型声明区 ------------------------------------------------------- */








/* 私有变量定义区 ----------------------------------------------------------- */




/** @defgroup LVGL_UI_INIT_Exported_Variables lvgl_ui_init exported variables
* @brief 全局变量定义
* @{
*/



/** defgroup LVGL_UI_INIT_Exported_Variables
* @}
*/





/* 私有函数定义区 ----------------------------------------------------------- */

static void printDir(const char * path)
{
    lv_fs_dir_t rddir;
    lv_fs_res_t ret;
    char fn[256];

    ret = lv_fs_dir_open(&rddir, path);
    if (ret != LV_FS_RES_OK)
    {
        printf("open directory '%s' fails\n", path);
        return;
    }

    do
    {
        ret = lv_fs_dir_read(&rddir, fn, sizeof(fn));
        if (ret != LV_FS_RES_OK)
        {
            printf("read directory '%s' fails\n", path);
            break;
        }
        printf("\tread dir: %s\n", fn);
    } while (*fn);

    ret = lv_fs_dir_close(&rddir);
    if (ret != LV_FS_RES_OK)
    {
        printf("close directory '%s' fails\n", path);
        return;
    }
}


/** @defgroup LVGL_UI_INIT_Exported_Functions lvgl_ui_init exported functions
* @brief 全局函数定义
* @{
*/


/**
********************************************************************************
* @brief    简要说明
* @details  详细说明
* @param    none
* @param[in]     a: 该参数用于输入
* @param[in,out] b: 该参数用于输入和输出
* @param[out]    c: 该参数用于输出
* @retval  none
* @retval  0 函数成功
* @retval  1 函数失败
* @return  返回0成功；否则失败
* @note    none
*/
void user_ui_init(void)
{
    lv_obj_t * label = lv_label_create(lv_screen_active());
    lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP);
    lv_label_set_text(label, "Recolor is not supported for v9 now.");
    lv_obj_set_width(label, 150);  /*Set smaller width to make the lines wrap*/
    lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0);
    lv_obj_align(label, LV_ALIGN_CENTER, 0, -40);
    lv_obj_set_style_text_color(label, lv_color_hex(0xff00ff), LV_PART_MAIN);

    lv_obj_t * btn = lv_button_create(lv_screen_active());
    lv_obj_t * btn_label = lv_label_create(btn);
    lv_label_set_text(btn_label, "Button 1");
    lv_obj_align_to(btn, label, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);

    lv_obj_t * btn2 = lv_button_create(lv_screen_active());
    lv_obj_t * btn_label2 = lv_label_create(btn2);
    lv_label_set_text(btn_label2, "Button 2");
    lv_obj_align_to(btn2, btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);

    lv_obj_t * btn3 = lv_button_create(lv_screen_active());
    lv_obj_t * btn_label3 = lv_label_create(btn3);
    lv_label_set_text(btn_label3, "Button 3");
    lv_obj_align_to(btn3, btn2, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);

    printDir(LV_FS_NATIVE_LETTER_STR "/");
    printDir(LV_FS_FATFS_LETTER_STR "/");
}

 


/** defgroup LVGL_UI_INIT_Exported_Functions
* @}
*/

/** defgroup LVGL_UI_INIT
* @}
*/


/*********************************** END OF FILE ******************************/
